<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.Config,java.util.Enumeration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Join into SView </title>
<link rel="icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/bootstrap_button.min.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/register.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/register.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
</head>
<body>
<%
     String lang = request.getParameter("lang");
     if(lang!=null &&lang.equals("zh")){
    	 request.getRequestDispatcher("register_zh.jsp").forward(request,response);
    	 return;
     }
     request.getSession().setAttribute("lang", lang);
%>
<div class="header_bar" style="height:45px;background-color:#000000">
<div class="bar-box">
<img src="/sview/icons/logo_white.png">
<div class="set_language">
   <%
    String WEBAPP = "/sview/";  
    String location = WEBAPP+"register";
     String from = request.getParameter("from");
     if(from!=null){
    	 from = java.net.URLEncoder.encode(from,"utf-8") ;
    	 location = location+"?from="+from;
     }
     String location_zh =WEBAPP+"register?lang=zh" ;
     if(from!=null)	
     	location_zh = location_zh+"&from="+from;
   %>
   <a class="op_lang" href="<%=location%>">English</a>
   <a class="op_lang" href="<%=location_zh%>">中文(简体)</a>
</div>
</div>
</div>
<div id="container" class="container">
   <% 
   String message = (String)request.getAttribute("message");
   if(message!=null && message.equals("userExist")){
	   out.write("<div>The user name existed. Please try another name.</div> ");
   }
%>
   <div class="signHeader"><span class="large">Sign Up</span><span class="link">Already have an account? 
   <%
         String loc = "/sview/login" ;
         if(from!=null){
        	 loc = loc+"?from="+from;
        	 }
        	 
      %>
      <a href="<%=loc%>">Sign in</a> 
   </span></div>
   <div id="register_section" class="section">
        <form action="confirmMail" method="post" id="registerForm">
        <div class="fields">
        	<label>Email</label>
        	<input class='ftext' type="text" name="email" id="email"/>
        	<span class="tips">
        	<span class="emborder1"></span><span  class="emborder2"></span>
        	Enter your email address
        	</span>
        	<span class="error-msg"></span>
        </div>
        <div class="fields">
        	<label>Username</label>
        	<input class='ftext' type="text" name="uid" id="uid"/>
        	<span class="tips" style="display:none">
        	<span class="emborder1"></span><span  class="emborder2"></span>
        	3-15 characters (letters, numbers or underline only)
        	</span>
        	<span class="error-msg"></span>
        </div>
        <div class="fields">
        	<label>Password</label>
        	 <input type="password" class='ftext' maxlength="20"  name="pwd" id="pwd">
        	<span class="tips">
        	<span class="emborder1"></span><span  class="emborder2"></span>
        	6-14 characters (letters or numbers only)
        	</span>
        	<span class="error-msg"></span>
        </div>
        <div class="fields">
        	<label>Re-enter Password</label>
        	<input type="password"  class='ftext' maxlength="20" id="repwd">
        	<span class="error-msg"></span>
        </div>
        <div class="fields">
        	<label>Preferred Languages</label>
        	<div id="p-lang" >
        		<span><input type="checkbox" value="en" name="prefer-langs" checked/>English</span>
        		<span><input type="checkbox" value="zh" name="prefer-langs"/>Chinese (Simplified)	</span>
        	</div>
        	<span class="error-msg"></span>
        </div>  
        <div class="operate">
        	<input type='submit' class="form-button btn btn-success" value="Sign up" onClick="return validateCheck();"/>
        </div> 
       <input type='hidden' name="display-lang" id="display-lang" value="en"/>
       <%if(from!=null){ 
        %>
         <input type='hidden' name="from" value="<%=from %>" />
        <%} %>
        </form>
	</div>
</div>
<jsp:include page="/vfooter.jsp"></jsp:include>
</body>
</html>